from sqlalchemy import Column, Integer, String, Text, DateTime, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
import datetime

Base = declarative_base()

class ShopifyPost(Base):
    __tablename__ = 'shopify_posts'

    id = Column(Integer, primary_key=True)
    title = Column(String(500))
    category = Column(String(100))
    author = Column(String(100))
    post_date = Column(String(100))
    url = Column(String(500), unique=True)
    views = Column(Integer, default=0)
    replies = Column(Integer, default=0)
    content = Column(Text)
    content_cn = Column(Text)
    title_cn = Column(String(500))
    summary = Column(Text)
    requirement = Column(Text)
    created_at = Column(DateTime, default=datetime.datetime.utcnow)

# 创建数据库连接
engine = create_engine('sqlite:///shopify_posts.db')
Base.metadata.create_all(engine)

# 创建会话
Session = sessionmaker(bind=engine) 